#!/bin/sh
#
# Automatically bump PORTREVISION of ports with touched distfiles.

fetch=0
tools_dir=$(cd $(dirname $0) && pwd)

args=`getopt f $*`
if [ $? -ne 0 ]; then
	echo "Usage: $0 [-f] port..."
	exit 2
fi

set -- $args
for i; do
	case "$i"
	in
		-f)
			fetch=1
			shift;;
		--)
			shift; break;;
	esac
done



for d in $@; do
	(
	cd $d || exit 1
	if [ $fetch = 1 ]; then
		${tools_dir}/rm-distfiles
	fi
	port fetch
	if [ -n "`svn status`" ]; then
		${tools_dir}/bump-portrevision
	fi
	)
done
